import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        Shape3D[] list = new Shape3D[n];

        for (int i = 0; i < n; i++) {
            String str = in.next();
            if (str.equals("cube")) {
                list[i] = new Cube(in.nextDouble());
            } else if (str.equals("cylinder")) {
                list[i] = new Cylinder(in.nextDouble(), in.nextDouble());
            }
        }
        double sumv = 0;
        double suma = 0;
        for (Shape3D i : list) {
            sumv += i.volume();
            suma += i.area();
        }

        System.out.printf("%.2f\n%.2f",suma,sumv);

    }

}


abstract class Shape3D implements Container {

}

class Cylinder extends Shape3D {

    private double r, h;

    public Cylinder(double r, double h) {
        super();
        this.r = r;
        this.h = h;
    }

    @Override
    public double area() {
        return pi * r * r * 2 + 2 * pi * r * h;
    }

    @Override
    public double volume() {
        return pi * r * r * h;
    }

}

class Cube extends Shape3D {

    private double a;

    public Cube(double a) {
        this.a = a;
    }

    @Override
    public double area() {

        return 6 * a * a;
    }

    @Override
    public double volume() {

        return a * a * a;
    }

}

interface Container {

    public static final double pi=3.1415926;
    public abstract double area();
    public abstract double volume();
    static double sumofArea(Container c[]) {
        double sum = 0;
        for(Container i:c) {
            sum += i.area();
        }
        return sum;
    };
    static double sumofVolume(Container c[]) {
        double sum = 0;
        for(Container i:c) {
            sum += i.volume();
        }
        return sum;
    }
}